package com.zw.design.pattern.creational.singleton.container;

import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/***
 * 容器单例模式  线程不安全的容器单例模式
 */
public class ContainerSingleton implements Serializable {

    private ContainerSingleton(){

    }

    private static Map<String,Object> map=new HashMap<String, Object>();


    public static  void putMap(String key,Object obj){
        if (StringUtils.isNotBlank(key)&&obj!=null){
            if (!map.containsKey(key)){
                map.put(key,obj);
            }
        }
    }

    public static Object getMap(String key){
        return  map.get(key);
    }


}
